<template>
  <view>
    <uni-card :title="userInfo.name||'暂无名字'" :sub-title="userInfo.email" :extra="userInfo.role" @click="onClick">
      <text class="uni-body">预约历史：</text>
    </uni-card>
    <view v-for="(item,index) in historyList" :key="index">
      <uni-card :title="item.campusObj.name+' '+item.building_name+'楼'+' '+ item.classroom_name+'室'+' '+ item.seat_num+'座'"
        :sub-title="item.end_time.slice(0,10)+' '+ item.start_time.slice(11,16)+'-'+item.end_time.slice(11,16)"
        :extra="item.statusName"  :thumbnail="item.campusObj.img">

      </uni-card>
    </view>
  </view>
</template>

<script>
  import {
    getAppointHistory
  } from "@/api/my.js"
  export default {
    data() {
      return {
        userInfo: {},
        historyList: [],
        dic:{'UNCHECKED':'等待签到','CHECKED & PROCESSING':'已签到','NORMALLY CLOSED':'已完成','BEING LATE':'失约'},

      };
    },
    onLoad() {
      this.userInfo = wx.getStorageSync('iseats_userInfo')

    },
    onShow() {
      this.getAppointHistory();
    },
    methods: {
      getAppointHistory() {
        getAppointHistory({
          user_id: this.userInfo.user_id
        }).then(res => {
          res.data.data.forEach(el => {
            el.campusObj = wx.getStorageSync("iseats_campus").find(item => item.value == el.campus);
            el.statusName=this.dic[el.status];
          })
          this.historyList = res.data.data;
        })
      }
    }
  }
</script>

<style lang="scss">

</style>